package com.hgy.carsb.service;


import com.hgy.carsb.dao.DescriptionMapper;
import com.hgy.carsb.entity.BenefitDetail;
import com.hgy.carsb.entity.IndicatorDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BenefitService {

    @Autowired
    private MainIndicatorService mainIndicatorService;

    @Autowired
    private DescriptionMapper descriptionMapper;

    public BenefitDetail getDetail(int year, int month, String zbCode, String prefix){
        IndicatorDetail indicatorDetail = mainIndicatorService.getSignalDetail(year, month, zbCode, prefix);
        BenefitDetail benefitDetail = new BenefitDetail(indicatorDetail);
        String monthDescription = descriptionMapper.getDescription(year, month, "monthly", zbCode);
        String yearDescription = descriptionMapper.getDescription(year, month, "yearly", zbCode);
        benefitDetail.setMonthDescription(monthDescription);
        benefitDetail.setYearDescription(yearDescription);
        return benefitDetail;
    }
}
